//
//  ActionBtn.m
//  YouthOlympic2014
//
//  Created by xiangpaopao on 14-6-27.
//  Copyright (c) 2014年 mitian. All rights reserved.
//



#import "ActionBtn.h"
#import "NSString+FontAwesome.h"

@interface ActionBtn ()

@property (nonatomic, strong) UILabel *iconLabel;
@property (nonatomic, strong) UILabel *selectedIconLabel;

@end


@implementation ActionBtn


-(NSString*)iconName
{
    return self.iconName;
}
-(NSString*)selectedIconName
{
    return self.selectedIconName;
}


-(void)setIconName:(NSString*)name
{
    if (self.iconLabel==nil) {
        UILabel *iconLabel = [[UILabel alloc] initWithFrame:CGRectMake(7, self.frame.size.height/2-7, 13, 13)];
        [iconLabel setTextColor:HEX2UIColor(0xb7d200)];
        [iconLabel setFont:[UIFont fontWithName:kFontAwesomeFamilyName size:13]];
        [iconLabel setText:[NSString fontAwesomeIconStringForIconIdentifier:name]];
        [self addSubview:iconLabel];
        self.iconLabel = iconLabel;
    }
}

-(void)setSelectedIconName:(NSString*)name
{
    if (self.selectedIconLabel==nil) {
        UILabel *selectedIconLabel = [[UILabel alloc] initWithFrame:CGRectMake(7, self.frame.size.height/2-7, 13, 13)];
        [selectedIconLabel setTextColor:HEX2UIColor(0xffffff)];
        [selectedIconLabel setFont:[UIFont fontWithName:kFontAwesomeFamilyName size:13]];
        [selectedIconLabel setText:[NSString fontAwesomeIconStringForIconIdentifier:name]];
        [self addSubview:selectedIconLabel];
        selectedIconLabel.hidden = YES;
        self.selectedIconLabel = selectedIconLabel;
    }
}

-(void)setSelected:(BOOL)selected
{
    [super setSelected:selected];
    NSLog(@"btn is selected ");
    self.iconLabel.hidden = selected;
    self.selectedIconLabel.hidden = !selected;
    if (selected) {
        [self setBackgroundColor:HEX2UIColor(0xb7d200)];
    }else{
        [self setBackgroundColor:HEX2UIColor(0xffffff)];
    }
}


@end
